package lumis.portal.propertybag;

import lumis.portal.PortalException;
import lumis.portal.PortalObjectNotFoundException;
import lumis.portal.manager.ManagerFactory;

/**
 * Property bag manager implementation. 
 * 
 * @hidden
 *
 * @version $Revision: 10825 $ $Date: 2009-08-04 12:36:40 -0300 (Tue, 04 Aug 2009) $
 * @since 5.0.0
 */
public class PropertyBagManager implements IPropertyBagManager
{
	public void add(PropertyBag bag) throws PortalException
	{
		ManagerFactory.getEntityManager().persist(bag);
	}

	public PropertyBag get(String propertyBagId) throws PortalException
	{
		PropertyBag bag = ManagerFactory.getEntityManager().find(PropertyBag.class, propertyBagId);
		if (bag != null)
			return bag;
		else
			throw new PortalObjectNotFoundException("PropertyBag id='" + propertyBagId + "' not found");
	}
	
	public void delete(PropertyBag bag) throws PortalException
	{
		ManagerFactory.getEntityManager().remove(bag);
	}
}
